import request from './request';
export default function requestAPi(url: string, type: string, params: object, headers?: any) {
	if (type === 'POST') {
		return request({
			url: url,
			method: type,
			params,
			headers: headers,
		});
	}
	if (type === 'GET') {
		return request({
			url: url,
			method: type,
			params,
			headers: headers,
		});
	}
	if (type === 'DELETE') {
		// let data = QS.stringify(params);
		return request({
			url: url,
			method: type,
			params,
			headers: headers,
		});
	}
	if (type === 'QS') {
		// let data = QS.stringify(params);
		return request({
			url: url,
			method: 'POST',
			data: params,
			headers: headers,
		});
	}
	if (type === 'RAW') {
		return request({
			url: url,
			method: 'POST',
			data: params,
			headers: { 'Content-Type': 'application/json' },
		});
	}
	if (type === 'formData') {
		return request({
			url: url,
			method: 'POST',
			data: params,
			headers: { 'Content-Type': 'multipart/form-data' },
		});
	}
	if (type === 'RAWDELETE') {
		return request({
			url: url,
			method: 'POST',
			data: params,
			headers: { 'Content-Type': 'multipart/form-data'},
		});
	}
}
